from contextlib import asynccontextmanager

from fastapi import FastAPI

from src.services.agno.lifespan import shutdown_agno, startup_agno




@asynccontextmanager
async def lifespan(app: FastAPI):
    """
    Actions to run on app startup
    
    This function uses fastAPI app to store data
    in the state, such as db_engine

    :param FastAPI app: _description_
    :return AsyncGenerator[None, None]: _description_
    """
    # startup
    startup_agno(app)
    
    yield
    
    # shutdown
    shutdown_agno(app)